<?php 
class Role extends BaseController_Controller {	

	public function __construct()
	{
		parent::__construct();			
		$this->load->library('sys/sysrole');		 
	}

	public function index()
	{		
		$this->appendhtmlwithjs('',$data,'admin/role.js',false);
	}

	public function delete()
	{		
		$id=json_decode($this->input->post('cb'),true);			
		if(count($id)>0)
		{
			$mdl=new SysRole();
			$rslt['success']=$mdl->Delete($id);			
		}
		echo json_encode($rslt);
	}

	public function save()
	{			
		$mdl=new SysRole( $this->input->post('roleid'));
		
		$id=$mdl->roleid;		
		$mdl->roleid=$this->input->post('roleid');
		$mdl->rolename=$this->input->post('rolename');
		$mdl->isactive=$this->input->post('isactive');				
		$b=false;
		$rslt=array();
		
		
		if(!$id){			
			$b=$mdl->Create($id);	
		}
		else{			
			if($this->input->post('iscreate'))
			{ 
				$b=false;
				$rslt['message']='Data Already Exist';
			}
			else 
			{
				$b=$mdl->Update();	
			}		
		}
		
		$rslt['success']=$b;
		echo json_encode($rslt);	
	}	

	

	
  }
